package com.springboot.demo.exception;

import com.springboot.demo.utils.ResponseResult;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
 * @author wubc683
 * @desc 业务异常返回数据
 * @date 2021-08-10 9:11
 */
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class BusinessException extends RuntimeException {
    private Integer code;
    private String message;

    public BusinessException(ResponseResult result) {
        this.code = result.getCode();
        this.message = result.getMessage();
    }

    public BusinessException(Integer c, String m) {
        this.code = c;
        this.message = m;
    }

//    // addition为补充信息
//    public BusinessException(ResponseResult result, String addition) {
//        this.code = result.getCode();
//        this.message = result.getMessage() + addition;
//    }
//
//    // addition为补充信息
//    public BusinessException(String addition, ResponseResult result) {
//        this.code = result.getCode();
//        this.message = addition + result.getMessage();
//    }
//
//    // addition为补充信息
//    public BusinessException(ResponseResult result, Object addition) {
//        this.code = result.getCode();
//        this.message = result.getMessage() + addition;
//    }
}